package com.zzs.judge.pojo.other;

import com.zzs.common.core.enums.CodeSubmitStatus;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author zzs
 * @date 2025/03/31
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
public class RunResult {
    private int status = 0;
    private String message = "";
    private String input = "";
    private String output = "";
    private String userOutput = "";
    private long useTime = 0;
    private long useMemory = 0;

    public static RunResult pass(long useTime, long useMemory) {
        return new RunResult(CodeSubmitStatus.PASS.getStatus(), CodeSubmitStatus.PASS.getMessage(), "", "", "", useTime, useMemory);
    }

    public static RunResult errorAnswer(String input, String output, String userOutput) {
        return new RunResult(CodeSubmitStatus.ERROR_ANSWER.getStatus(), CodeSubmitStatus.ERROR_ANSWER.getMessage(), input, output, userOutput, 0, 0);
    }

    public static RunResult exceedMemory() {
        return new RunResult(CodeSubmitStatus.EXCEED_MEMORY.getStatus(), CodeSubmitStatus.EXCEED_MEMORY.getMessage(), "", "", "",  0, 0);
    }

    public static RunResult exceedTime() {
        return new RunResult(CodeSubmitStatus.EXCEED_TIME.getStatus(), CodeSubmitStatus.EXCEED_TIME.getMessage(), "", "", "",  0, 0);
    }

    public static RunResult errorRun(String message) {
        return new RunResult(CodeSubmitStatus.ERROR_RUN.getStatus(), message, "", "", "",  0, 0);
    }

    public static RunResult errorServer() {
        return new RunResult(CodeSubmitStatus.ERROR_SERVER.getStatus(), CodeSubmitStatus.ERROR_SERVER.getMessage(), "", "", "",  0, 0);
    }
}
